﻿using AutoMapper;
using MiniErp.Common.DB.MySqlDB;
using MiniErp.Entity.DataStreams.BOs;
using MiniErp.Entity.DataStreams.DOs.Notice;
using MiniErp.Entity.DataStreams.DTOs.Notice;
using MiniErp.Repository.BaseRepository;
using MiniErp.Repository.UnitOfWorkCore;
using MiniErp.Service.BusinessService.IService.Notice;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MiniErp.Service.BusinessService.Service.Notice
{
    public class UserInfoNoticesReplyService : BaseService, IUserInfoNoticesReplyService
    {
        /// <summary>
        /// 用户公告仓储
        /// </summary>
        private readonly BaseRepository<MysqlContext, UserInfoNoticesReply> _unrr;
        public UserInfoNoticesReplyService(IMysqlUnitOfWork mysqlUnitOfWork, IMapper mapper) : base(mysqlUnitOfWork, mapper)
        {
            _unrr = _mysqlUnitOfWork.CreateRepository<MysqlContext, UserInfoNoticesReply>();
        }


        public int AddUserInfoNoticesReplys(List<AddUserInfoNoticesReplyDTO> addUserInfoNoticesReplyDTOs)
        {
            var userNoticesReply = _mapper.Map<List<UserInfoNoticesReply>>(addUserInfoNoticesReplyDTOs);
            _unrr.AddInfo(userNoticesReply);
            return addUserInfoNoticesReplyDTOs.Count;
        }

        public int DeleteUserInfoNoticesReplys(List<UserInfoNoticesReply> userNoticesId)
        {
            _unrr.DeleteInfo(userNoticesId);
            return userNoticesId.Count;
        }

        public Task<List<UserInfoNoticesReplyDTO>> GetUserInfoNoticesReplyByNoticesIdAsync(int noticesid, int page, int num)
        {
            throw new NotImplementedException();
        }

        public Task<List<UserInfoNoticesReply>> GetUserInfoNoticesReplyByNoticesIdAsync(int noticesid)
        {
            return _unrr.GetReadOnlyInfoAsyncs(item => item.NoticeId == noticesid);
        }

        public Task<List<UserInfoNoticesReply>> GetUserInfoNoticesReplyByNoticesIdAndJobsIdAsync(int noticesid, int jobsid)
        {
            return _unrr.GetReadOnlyInfoAsyncs(item => item.NoticeId == noticesid && item.userInfo.JobsId == jobsid);
        }
        public Task<List<UserInfoNoticesReplyDTO>> GetUserInfoNoticesReplyByUserIdAndTimeAsync(int uid, DateTime starttime, DateTime endtime, int page, int num)
        {
            throw new NotImplementedException();
        }

        public Task<bool> UpdateUserInfoNoticesReplyAsync(UpdateUserInfoNoticesReplyDTO NoticesDTO)
        {
            throw new NotImplementedException();
        }
    }
}
